//
// Created by Gorun on 2022/5/3.
//

#ifndef LOXPP_LOXFUNCTION_H
#define LOXPP_LOXFUNCTION_H

#include <any>
#include <memory>
#include <string>
#include <vector>
#include "LoxCallable.h"
#include "LoxInstance.h"

class Environment;
struct Function;

class LoxFunction: public LoxCallable {
    std::shared_ptr<Function> declaration;
    std::shared_ptr<Environment> closure;

public:
    const bool isNative;
    const bool isInitializer;
    // LoxFunction(std::shared_ptr<Function> declaration);
    LoxFunction(std::shared_ptr<Function> declaration,
                std::shared_ptr<Environment> closure,
                bool isNative, bool isInitializer);
    shared_ptr<LoxFunction> bind(shared_ptr<LoxInstance> instance);
    std::string toString() override ;
    int arity() override;
    std::any call(Interpreter& interpreter,
                  std::vector<std::any> arguments) override;
};

#endif //LOXPP_LOXFUNCTION_H
